package cn.ulc.socket.common.config;
import cn.ulc.store.amiExt.*;
import cn.ulc.store.dao.BaseDao;
import com.ibeetl.starter.BeetlSqlCustomize;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.mapper.builder.MapperConfigBuilder;
import org.beetl.sql.ext.spring4.SqlManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BaseConfig {
    @Bean
    public BeetlSqlCustomize beetlSqlCustomize(){
        return  new BeetlSqlCustomize(){
            public void customize(SqlManagerFactoryBean sqlManagerFactoryBean){
                try {
                    SQLManager sqlManager = sqlManagerFactoryBean.getObject();
                    MapperConfigBuilder builder = sqlManager.setBaseMapper(BaseDao.class).getBuilder();
                    builder.addAmi("update",new UpdateBatchAmiExt());//可用
                    builder.addAmi("findOne",new FindByIdAndDeletedAmiExt());//可用
                    builder.addAmi("save",new SaveAmiExt());//可用
                    builder.addAmi("delete",new DeleteBatchAmiExt());//可用
                    builder.addAmi("saveAll",new SaveAllAmiExt());//可用
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
    }
}
